﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CarLoanSystem.Entity;

namespace CarLoanSystem
{
    public partial class frmLigigationInfoDetail : Form
    {
        private static LitigationDetailItem litigationDetailItem;
        private static int litigationID;
        public frmLigigationInfoDetail(int id)
        {
            InitializeComponent();
            litigationID = id;
        }

        public frmLigigationInfoDetail(int litigationDetailId, int id)
        {
            InitializeComponent();
            this.txtDetail.Enabled = false;
            this.btnSave.Visible = false;
            litigationDetailItem = DAL.LitigationInfoDetailDAL.LoadLitigationDetail(litigationDetailId);
            this.txtDetail.Text = litigationDetailItem.LITIGATION_DETAIL;
            this.dtpDate.Value = litigationDetailItem.LITIGATION_DETAIL_DATE;
            litigationID = id;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            litigationDetailItem = new LitigationDetailItem();
            litigationDetailItem.LITIGATION_DETAIL = this.txtDetail.Text;
            litigationDetailItem.LITIGATION_DETAIL_DATE = dtpDate.Value;
            litigationDetailItem.LITIGATION_ID = litigationID;
            DAL.LitigationInfoDetailDAL.Insert(litigationDetailItem);
            MessageBox.Show("บันทึกข้อมูลสำเร็จ", "รายละเอียดการติดต่อ");
            this.Close();
        }

        private void btnCancal_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
